package com.anzia.set;

import java.util.HashSet;

/**
 *@ClassName HashSet1_Demo
 *@Description
 *@Author Anzia.
 *@Date 2021/4/10 14:12
 *@Version 1.0
 **/
public class HashSet1_Demo {
    public static void main(String[] args) {
        //创建集合
        HashSet<Person> hashSet = new HashSet<>();
        Person person1 = new Person("刘德华", 20);
        Person person2 = new Person("周星驰", 21);
        Person person3 = new Person("郭德纲", 22);

        //添加数据
        hashSet.add(person1);
        hashSet.add(person2);
        hashSet.add(person3);
        hashSet.add(new Person("刘德华",20));

        System.out.println(hashSet.size());
        System.out.println(hashSet);

    }
}
